﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace iRingtones
{
    public class Locations
    {
        /// <summary>
        /// Location to the Nero AAC Encoder
        /// </summary>
        public string NeroAacEnc
        {
            get;
            set;
        }

        /// <summary>
        /// Location to the users iTunes Music Library. Vista example would be C:\Users\BillyBob\Music\iTunes\iTunes Music
        /// </summary>
        public string iTunesLibrary
        { 
            get; 
            set; 
        }

        /// <summary>
        /// Serializes the locations out to an xml file for saving.
        /// </summary>
        /// <param name="Filename"></param>
        public void Save(string Filename)
        {
            Stream stream = File.Create(Filename);

            XmlSerializer serializer = new XmlSerializer(typeof(Locations));
            serializer.Serialize(stream, this);
            stream.Close();
        }

        /// <summary>
        /// Loads an item via Xml Deserialization
        /// </summary>
        /// <param name="Filename">The Xml document to deserialize.</param>
        /// <returns></returns>
        public Locations Load(string Filename)
        {
            Stream stream = File.OpenRead(Filename);

            Locations obj = new Locations();
            XmlSerializer serializer = new XmlSerializer(typeof(Locations));
            obj = (Locations)serializer.Deserialize(stream);

            stream.Close();
            return obj;
        }
    }
}
